/*
* $Id: Components.cpp 156 2010-09-28 19:00:52Z volok-aleksej@yandex.ru $
*
* Copyright 2008 by Volokitin Alexey
* All rights reserved
*
*/
#include "Common/include.h"
#include "Components.h"
#include "Journal/Styles.h"
#include "Journal/QueenBeeManager.h"
#include "Journal/InspectManager.h"
#include "Journal/FamilyManager.h"
#include "Journal/HousingManager.h"
#include "Settings/MainSettings.h"
#include "Settings/Journal/JournalSettings.h"
#include "Settings/Journal/PointViewSettings.h"
#include "Settings/Journal/FamilyViewSettings.h"
#include "Settings/Journal/RecordViewSettings.h"
#include "Visual/Settings/SettingsVisualComponent.h"
#include "Visual/Journal/JournalVisualComponent.h"
#include "Visual/Journal/TreeView/JournalTreeView.h"

/************************************************************************/
/*                       CSettingsComponent                             */
/************************************************************************/
CSettingsComponent::CSettingsComponent()
: CComponent(SETTINGS_ID, new CSettingsVisualComponent){}
CSettingsComponent::~CSettingsComponent(){}

void CSettingsComponent::Init(){
	m_aSettings.push_back(new CMainSetting);
}

/************************************************************************/
/*                       CJournalComponent                              */
/************************************************************************/
CJournalComponent::CJournalComponent()
: CComponent(JOURNAL_CAPTION_ID, new CJournalVisualComponent(this)){}
CJournalComponent::~CJournalComponent(){
	for(std::vector<IJournalView*>::iterator it = m_aJournalView.begin(); it != m_aJournalView.end(); it++)
		(*it)->Free();
}
void CJournalComponent::Init(){
	IJournalComponent::GetFamilyManager()->Init();
	IJournalComponent::GetInspectManager()->Init();
	IJournalComponent::GetQueenBeeManager()->Init();
	IJournalComponent::GetHousingManager()->Init();
	m_aJournalView.push_back(new CJournalTreeView);
	m_aSettings.push_back(new CJournalSettings(this));
	m_aSettings.push_back(new CPointViewSettings);
	m_aSettings.push_back(new CFamilyViewSettings);
	m_aSettings.push_back(new CRecordViewSettings);
}


IJournalView* CJournalComponent::GetView(const std::tstring& strStyleName){
	for(std::vector<IJournalView*>::iterator it = m_aJournalView.begin(); it != m_aJournalView.end(); it++){
		if((*it)->GetStyleView()->GetNameStyle() == strStyleName)
			return *it;
	}
	return NULL;
}
std::vector<std::tstring> CJournalComponent::GetStyleNames(){
	std::vector<std::tstring> aStyles;
	for(std::vector<IJournalView*>::iterator it = m_aJournalView.begin(); it != m_aJournalView.end(); it++)
		aStyles.push_back((*it)->GetStyleView()->GetNameStyle());
	return aStyles;
}

CQueenBeeManager* CJournalComponent::GetQueenBeeManager(){
	return m_pQueenBeeManager;
}
